Graphical user interfaces (GUIs) ของ โปรแกรมเฮลโลเวิลด์

ActionScript (Macromedia flash mx)

 this.createTextField ("hello_txt",0,10,10,100,20) ;
this.hello_txt.text="Hello, world";

AppleScript

See also TUI section.

display dialog "Hello World!" buttons {"OK"} default button 1

ไฟล์:Ashelloworlddisplay.png

Or to have the OS synthesize it and literally speak out the words "hello world!" (with no comma, as that would cause the synthesizer to pause)

say "Hello world!"

boo

See also TUI section.

import System.Drawingimport System.Windows.Formsf = Form ()f.Controls.Add (Label (Text: "Hello, World!", Location: Point (40,30)))f.Controls.Add (Button (Text: "Ok", Location: Point (50, 55) , Click: {Application.Exit () }))Application.Run (f)

Functional equivalent of C# program below.

C#

See also TUI section.

using System;using System.Drawing;using System.Windows.Forms;class HelloWorldForm : Form {    public static void Main () {        Application.Run (new HelloWorldForm ()) ;    }   public HelloWorldForm () {       Label label = new Label () ;       label.Text = "Hello, World!";       label.Location = new Point (40,30) ;       Controls.Add (label) ;       Button button = new Button () ;       button.Text = "OK";       button.Location = new Point (50,55) ;       Controls.Add (button) ;       button.Click += new EventHandler (OnButtonOk) ;   }    void OnButtonOk (Object sender, EventArgs e) {       Application.Exit () ;   }}

or ||

using System;using System.Drawing;using System.Windows.Forms;namespace HelloWorld{    public class HelloWorld : Form    {        public HelloWorld ()        {            ShowMessage () ;        }                [STAThread]        static void Main ()         {            Application.Run (new HelloWorld ()) ;        }                private void ShowMessage ()        {            MessageBox.Show (                 "Hello World!!!",                 "Hello World - C#",                 MessageBoxButtons.OK,                 MessageBoxIcon.Information,                 MessageBoxDefaultButton.Button1 ) ;        }    }}


ไฟล์:HelloWorld.JPG

Cocoa or GNUStep (In Objective C)

#import <Cocoa/Cocoa.h>

@interface hello : NSObject {}@end@implementation hello- (void) awakeFromNib{	     NSBeep () ; // we don't need this but it's conventional to beep                // when you show an alert     NSRunAlertPanel (@"Message from your Computer", @"Hello, world!", @"Hi!",                     nil, nil) ;}@end

Curl

{curl 3.0, 4.0 applet}{curl-file-attributes character-encoding = "utf-8"}Hello, world!

Delphi, Kylix

program Hello_World;uses      Windows;   begin  ShowMessage ("Hello, world!") ;end.

Euphoria

MS-Windows only - basic.

include msgbox.eif message_box ("Hello, world!", "Hello", 0) then end if

MS-Windows only - using Win32Lib library

include win32lib.ewcreateForm ({       ";Window; Hello",       ";Label;  Hello, World!"   })include w32start.ew

FLTK2 (in C++)

#include <fltk/Window.h>#include <fltk/Widget.h>#include <fltk/run.h>using namespace fltk;   int main (int argc, char **argv){    Window *window = new Window (300, 180) ;    window->begin () ;        Widget *box = new Widget (20, 40, 260, 100, "Hello, World!") ;        box->box (UP_BOX) ;        box->labelfont (HELVETICA_BOLD_ITALIC) ;        box->labelsize (36) ;        box->labeltype (SHADOW_LABEL) ;     window->end () ;     window->show (argc, argv) ;    return run () ;}

Gambas

See also TUI section.

PUBLIC SUB Main ()  Message.Info ("Hello, world!")END

ไฟล์:Gambashelloworld.png

GTK+ (in C++)

#include <iostream>#include <gtkmm/main.h>#include <gtkmm/button.h>#include <gtkmm/window.h>using namespace std;class HelloWorld : public Gtk::Window {public:  HelloWorld () ;  virtual ~HelloWorld () ;protected:  Gtk::Button m_button;  virtual void on_button_clicked () ;};HelloWorld::HelloWorld (): m_button ("Hello, world!") {    set_border_width (10) ;    m_button.signal_clicked ().connect (SigC::slot (*this,                                      &HelloWorld::on_button_clicked)) ;    add (m_button) ;    m_button.show () ;}HelloWorld::~HelloWorld () {}void HelloWorld::on_button_clicked () {    cout << "Hello, world!" << endl;}int main (int argc, char *argv[]) {    Gtk::Main kit (argc, argv) ;    HelloWorld helloworld;    Gtk::Main::run (helloworld) ;    return 0;}

GTK+ (in Python)

from gtk import *

window = Window (WINDOW_TOPLEVEL)window.set_title ("Hello World!")window.connect ("destroy", main_quit)window.add (VBox ())window.child.pack_start (Label ("Hello World!"))button=Button ("OK")window.child.pack_end (button)button.connect ("clicked", main_quit)window.show_all ()main ()

or

import gtkgtk.MessageDialog (message_format="Hello World!").run ()

Gtk# (in C#)

using Gtk;

using GtkSharp;using System;class Hello {    static void Main ()    {        Application.Init () ;        Window window = new Window ("") ;        window.DeleteEvent += cls_evn;        Button close  = new Button ("Hello World") ;        close.Clicked += new EventHandler (cls_evn) ;        window.Add (close) ;        window.ShowAll () ;                Application.Run () ;    }    static void cls_evn (object obj, EventArgs args)    {        Application.Quit () ;    }}

GTK+ 2.x (in Euphoria)

include gtk2/wrapper.eInfo (NULL,"Hello","Hello World!")

ไฟล์:EuphoriaHelloWorld.png

Java

See also TUI section.

import javax.swing.JOptionPane;public class Hello {    public static void main (String[] args) {        JOptionPane.showMessageDialog (null, "Hello, world!!") ;    }}

Java applet

Java applets work in conjunction with HTML files.
<HTML><HEAD><TITLE>Hello World</TITLE></HEAD><BODY>HelloWorld Program says:<APPLET CODE="HelloWorld.class" WIDTH=600 HEIGHT=100></APPLET>


</BODY></HTML>
import import public class HelloWorld extends Applet {  public void paint (Graphics g) {    g.drawString ("Hello, world!", 100, 50) ;  }}

JavaScript and JScript

JavaScript (an implementation of ECMAScript) is a client-side scripting language used in HTML files. The following code can be placed in any HTML file: { alert ("Hello, world!") ; } //--></script> <a href="#" onclick="helloWorld () ; return false;">Hello World Example</a>An easier method uses JavaScript implicitly, directly calling the reserved alert function. Cut and paste the following line inside the <body> .... </body> HTML tags.
<a href="#" onclick="alert ('Hello, world!') ; return false;">Hello World Example</a>
An even easier method involves using popular browsers' support for the virtual 'javascript' protocol to execute JavaScript code. Enter the following as an Internet address (usually by pasting into the address box) :
javascript:alert ('Hello, world!') ;

ไฟล์:Js-hello world.png

There are many other ways:
javascript:document.write ('Hello, world!\n') ;

K

This creates a window labeled "Hello world" with a button labeled "Hello world".

hello:hello..l:"Hello world"hello..c:`button`show$`hello

OPL

See also TUI section.

(On Psion Series 3 and later compatible PDAs.)

PROC guihello:  ALERT ("Hello, world!","","Exit")ENDP

or

PROC hello:   dINIT "Window Title"   dTEXT "","Hello World"   dBUTTONS "OK",13   DIALOGENDP

Qt toolkit (in C++)

#include <qapplication.h>#include <qpushbutton.h>#include <qwidget.h>#include <iostream>class HelloWorld : public QWidget{    Q_OBJECTpublic:    HelloWorld () ;    virtual ~HelloWorld () ;public slots:    void handleButtonClicked () ;    QPushButton *mPushButton;};HelloWorld::HelloWorld () :    QWidget () ,    mPushButton (new QPushButton ("Hello, World!", this)){    connect (mPushButton, SIGNAL (clicked ()) , this, SLOT (handleButtonClicked ())) ;}HelloWorld::~HelloWorld () {}void HelloWorld::handleButtonClicked (){    std::cout << "Hello, World!" << std::endl;}int main (int argc, char *argv[]){    QApplication app (argc, argv) ;    HelloWorld helloWorld;    app.setMainWidget (&helloWorld) ;    helloWorld.show () ;    return app.exec () ;}

or

#include <QApplication>#include <QPushButton>int main (int argc, char *argv[]){  QApplication app (argc, argv) ;  QPushButton hello ("Hello world!") ;  hello.resize (100, 30) ;  hello.show () ;  hello.connect (&hello, SIGNAL (clicked ()) , SLOT (close ())) ;  return app.exec () ;}

REAL


RPL

See also TUI section.

(On Hewlett-Packard


RTML

Hello ()

TEXT "Hello, world!"

Ruby with WxWidgets

See also TUI section.

require 'wxruby'class HelloWorldApp < Wx::App def on_init  ourFrame = Wx::Frame.new (nil, -1, "Hello, world!").show  ourDialogBox = Wx::MessageDialog.new (ourFrame, "Hello, world!", "Information:", \                 Wx::OK|Wx::ICON_INFORMATION).show_modal endendHelloWorldApp.new.main_loop


Ruby with GTK+

See also TUI section.

require 'gtk2'Gtk.initwindow = Gtk::Window.newwindow.signal_connect ("delete_event") { Gtk.main_quit; false }button = Gtk::Button.new ("Hello World")button.signal_connect ("clicked") { Gtk.main_quit; false }window.add (button)window.show_allGtk.main

SWT (in Java)

import org.eclipse.swt.SWT;import org.eclipse.swt.layout.RowLayout;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Label;public class SWTHello {    public static void main (String [] args) {        Display display = new Display () ;        final Shell shell = new Shell (display) ;        RowLayout layout = new RowLayout () ;        layout.justify = true;        layout.pack = true;        shell.setLayout (layout) ;        

ไฟล์:SWT Hello World.gif

Tcl/Tk

See also TUI section.

label .l -text "Hello, world!"pack .l

Python with Tkinter

See also TUI section.

import Tkinterr = Tkinter.Tk ()w = Tkinter.Label (r, text="Hello, world!")w.pack ()r.mainloop ()

or, more primitively:

import   

Visual Basic including VBA

Sub Main ()    MsgBox "Hello, world!"End Sub

Visual Prolog note box

#include @"pfc\vpi\vpi.ph"goal  vpiCommonDialogs::note ("Hello World!").

Windows API (in C)

This uses the Windows API to create a full window containing the text. Another example below uses the built-in MessageBox function instead.

#include <windows.h>LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM) ;char szClassName[] = "MainWnd";int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,                   int nCmdShow){  HWND hwnd;  MSG msg;  WNDCLASSEX wincl;  wincl.cbSize = sizeof (WNDCLASSEX) ;  wincl.cbClsExtra = 0;  wincl.cbWndExtra = 0;  wincl.style = 0;  wincl.hInstance = hInstance;  wincl.lpszClassName = szClassName;  wincl.lpszMenuName = NULL; //No menu  wincl.lpfnWndProc = WindowProcedure;  wincl.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1) ; //Color of the window  wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; //EXE icon  wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ; //Small program icon  wincl.hCursor = LoadCursor (NULL, IDC_ARROW) ; //Cursor  if (!RegisterClassEx (&wincl))        return 0;  hwnd = CreateWindowEx (0, //No extended window styles        szClassName, //Class name        "", //Window caption        WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,        CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top                                      //positions of the window        120, 50, //Width and height of the window,        NULL, NULL, hInstance, NULL) ;  //Make the window visible on the screen  ShowWindow (hwnd, nCmdShow) ;  //Run the message loop  while (GetMessage (&msg, NULL, 0, 0) >0)  {        TranslateMessage (&msg) ;        DispatchMessage (&msg) ;  }  return msg.wParam;}LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message,                                 WPARAM wParam, LPARAM lParam){  PAINTSTRUCT ps;  HDC hdc;  switch (message)  {  case WM_PAINT:        hdc = BeginPaint (hwnd, &ps) ;        TextOut (hdc, 15, 3, "Hello, world!", 13) ;        EndPaint (hwnd, &ps) ;        break;  case WM_DESTROY:        PostQuitMessage (0) ;        break;  default:        return DefWindowProc (hwnd, message, wParam, lParam) ;  }  return 0;}

Or, much more simply:

#include <windows.h>int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,                   int nCmdShow){    MessageBox (NULL, "Hello, world!", "", MB_OK) ;    return 0;}

Windows Script Host with VBScript

<job id="HelloWorld">        <script language="VBScript">                WScript.Echo "Hello, world!"        </script></job>

Windows Script Host with JScript

<job id="HelloWorld">        <script language="JScript">                WScript.Echo ( "Hello, world!" ) ;        </script></job>

XSL (T)

There are many ways to do this in XSL, the simplest being:

<xsl:template match="/">  <xsl:text>Hello, world!</xsl:text></xsl:template>

If nested similar to the HTML version, it would be:

<xsl:template match="/">  <html>    <body>      <h1>Hello, world!</h1>    </body>  </html></xsl:template>

XUL

Type the following in a text file (e.g. hello.world.xul) and then open with Mozilla Firefox.

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">  <box align="center" pack="center" flex="1">    <description>Hello, world</description>  </box></window>

ใกล้เคียง

โปรแกรมเฮลโลเวิลด์ โปรแกรมจัดการรหัสผ่าน โปรแกรมหน้า วิญญาณอาฆาต โปรแกรมความภักดี โปรแกรมตรวจแก้จุดบกพร่องกนู โปรแกรมป้องกันไวรัส โปรแกรมประยุกต์ โปรแกรมอรรถประโยชน์ โปรแกรมคอมพิวเตอร์ โปรแกรมประยุกต์บนเว็บ